<?php
namespace api\models;

use api\models\base\BaseForm;
use common\models\Active;

/**
 * 检查 活动商品 是否有效
 */
class AstatusForm extends BaseForm
{
    /* 售罄js文件设置 */
    public function soldOutJsSetting( $active_id = 0, $good_id = 0 )
    {
        $ret2reponse = [
            'status' => '202',
            'msg' => '活动商品已下架或者已售完'
        ];

        $dir_path = \Yii::$app->params[ 'root_path' ] . 'astatus';
        $file_path = $dir_path . '/' . $active_id . '_' . $good_id . '.js';

        // 检查目录是否存在 / 需要创建
        $ret2mkdir = $this->sp_mkdirs( $dir_path );
        $ret2setUnseldJs = file_put_contents( $file_path, json_encode( $ret2reponse ) );

        return $ret2reponse;
    }

}
